package com.beauty.dressing.module.mine.activity;

import android.util.Log;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.beauty.dressing.R;
import com.beauty.dressing.common.base.BaseActivity;
import com.beauty.dressing.common.bean.LeaseBean;
import com.beauty.dressing.common.bean.User;
import com.beauty.dressing.common.utils.Constants;
import com.beauty.dressing.logic.control.LBController;
import com.beauty.dressing.module.mine.persenter.MyLeaseControl;
import com.beauty.dressing.module.mine.persenter.MyLeasePresenter;

public class ClearingActivity extends BaseActivity {
    LeaseBean bean;
    TextView tv_order_price, tv_deposit;

    @Override
    public void setContentView() {
        setContentView(R.layout.activity_clearing);
    }

    @Override
    public void findView() {
        TextView title_txt = findViewById(R.id.title_txt);
        title_txt.setText("预付定金结算");
        findViewById(R.id.left_img_btn).setOnClickListener(this);
        findViewById(R.id.btn_complete).setOnClickListener(this);

        tv_order_price = findViewById(R.id.tv_order_price);
        tv_deposit = findViewById(R.id.tv_deposit);
        Log.e(TAG, "-----" + getIntent().getStringExtra(Constants.AGREEMENT));
    }

    @Override
    public void initData() {
        bean = (LeaseBean) getIntent().getSerializableExtra("data");
        tv_order_price.setText(bean.getDeposit());
        tv_deposit.setText(bean.getDeposit());
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.left_img_btn:
                this.finish();
                break;
            case R.id.btn_complete:
                User user = LBController.getInstance().getCacheManager().getLoginUser();
                myLeasePresenter.lostApply(user.member_id, bean.getId(), user.token);
                break;
        }
    }

    MyLeasePresenter myLeasePresenter = new MyLeasePresenter(new MyLeaseControl() {
        @Override
        public void onLostApply(boolean isSuccess, int code, String message) {
            Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
        }
    });
}

